package com.woniu.product.controller;

import com.woniu.common.dto.MySkuOrderDto;
import com.woniu.common.util.PageParam;
import com.woniu.common.util.ResponseData;
import com.woniu.product.pojo.TOrderDetail;
import com.woniu.product.service.TOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 杜梅杰
 * @Description
 * @Date 2024/5/23 13:07
 */
@RestController
public class OrderDetailController {
    @Autowired
    private TOrderDetailService orderDetailService;

    /**
     * 批量插入订单详情
     */
    @PostMapping("/batchAddOrderDetail")
    public void batchAddOrderDetail(@RequestBody List<TOrderDetail> orderDetail) {
        orderDetailService.saveBatch(orderDetail);
    }

    /**
     * 根据用户ID查询订单详情
     */
    @PostMapping("/queryDetailByPhone")
    public ResponseData<?> queryDetailByPhone(String phone) {
        return orderDetailService.queryDetailByPhone(phone);
    }
    
    /**
     * 查订单详情分页
     */
    @PostMapping("/queryOrders")
    public ResponseData<?> queryOrders(@RequestBody PageParam<MySkuOrderDto> pageParam) {
        return orderDetailService.queryOrders(pageParam);
    }

    /**
     * 查看已收货订单详情
     */
    @PostMapping("/queryOrdersOk")
    public ResponseData<?> queryOrdersOk(@RequestBody PageParam<MySkuOrderDto> pageParam) {
        return orderDetailService.queryOrdersOk(pageParam);
    }

    /**
     * 获取人气商品
     */
    @GetMapping("/queryhostSks")
    public ResponseData<?> queryhostSks() {
        return orderDetailService.queryhostSks();
    }
    
    /**
     * 获取特色商品
     */
    @GetMapping("/queryTese/{phone}")
    public ResponseData<?> queryTese(@PathVariable("phone") String phone) {
        return orderDetailService.queryTeseSku(phone);
    }
}
